package com.test.mylotterysystem.dao.Mapper;

import com.test.mylotterysystem.dao.DO.ActivityDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {

    @Insert("insert into activity (activity_name, description, status)" +
            " values (#{activityName}, #{description}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertActivity(ActivityDO activityDO);

    @Select("select count(*) from activity")
    int activityCount();

    @Select("select * from activity order by id desc limit #{offset} , #{pageSize}")
    List<ActivityDO> getActivityList(int offset, Integer pageSize);

    @Select("select * from activity where id=#{activityId};")
    ActivityDO selectActivityById(Long activityId);

    @Update("update activity set status = #{name} where id = #{activityId}")
    void updateStatus(Long activityId, String name);
}
